/**
 * zmn文章模块-配件编辑
 * 文件命名格式：zmn.模块.表/功能.jas
 * @author heguanghua
 * @since 2018/10/18
 */
layui.define(['form', 'layedit', 'laydate', 'upload'], function () {
    window.$ = layui.$;
    let form = layui.form;
    let layer = layui.layer;
    let upload = layui.upload;
    let skuId = json.part.skuId;


    // 分类下拉框联动
    zmnLayUtil.laySelectLinkage($, form, {
        option: {
            enableOnly: false
        }
        , selectId1: "categOneId"
        , selectUrl1: "/part/category/second/ajax/select.action"
        , selectId2: "categId"
    });

    // 表单验证
    zmnLayUtil.layFormVerify(form);


    // 提交
    form.on('submit(zmn-part-form-submit)', function (obj) {
        let data = obj.field;
        zmnLayUtil.ajaxResultDTOJson(parent.layui.layer, "/part/ajax/addEdit.action", data, 0, function () {
            zmnLayUtil.closeThisTabs();
        });
        return false;
    });

    $("#cancel").on("click", function (e) {
        zmnLayUtil.closeThisTabs();
    });

    zmnImageUtil.uploaderImageRender("img1", {
            imageName: "imgSrc",
            imageUrl: json.part.imgSrc,
            imageTitle: "配件图片1"
        }, {
            url: `/part/ajax/uploaderImage.action?skuId=${skuId}&suffix=img1&param=imgSrc`
        }
    );
    zmnImageUtil.uploaderImageRender("img2", {
            imageName: "imgSrc2",
            imageUrl: json.part.imgSrc2,
            imageTitle: "配件图片2"
        }, {
            url: `/part/ajax/uploaderImage.action?skuId=${skuId}&suffix=img2&param=imgSrc2`
        }
    );
    zmnImageUtil.uploaderImageRender("img3", {
            imageName: "imgSrc3",
            imageUrl: json.part.imgSrc3,
            imageTitle: "配件图片3"
        }, {
            url: `/part/ajax/uploaderImage.action?skuId=${skuId}&suffix=img3&param=imgSrc3`
        }
    );
    zmnImageUtil.uploaderImageRender("img4", {
            imageName: "imgSrc4",
            imageUrl: json.part.imgSrc4,
            imageTitle: "配件图片4"
        }, {
            url: `/part/ajax/uploaderImage.action?skuId=${skuId}&suffix=img4&param=imgSrc4`
        }
    );
    zmnImageUtil.renderImage();
});

